package com.zyh.demo2;

import java.util.Scanner;

public class SwitchDemo1 {
    public static void main(String[] args) {
//        输入水果
        System.out.println("请输入水果的名称");
        String fruit = new Scanner(System.in).nextLine();
        if (!"苹果".equals(fruit) && !"香蕉".equals(fruit) && !"榴莲".equals(fruit) && !"西瓜".equals(fruit)) {
            System.err.println("没有这个水果");
            return;
        }
        switch (fruit) {
            case "苹果":
                System.out.println("苹果6块1斤");
                break;
            case "香蕉":
                System.out.println("香蕉3块1斤");
                break;
            case "榴莲":
                System.out.println("榴莲20块1斤");
                break;
            case "西瓜":
                System.out.println("西瓜0.8块1斤");
                break;
        }

    }

    public static void main1(String[] args) {
//        接收成绩
        System.out.println("请输入成绩：");
        double score = new Scanner(System.in).nextDouble();
        if (score >= 0 && score <= 100) {
            switch ((int) score / 10) {
                case 6:
                    System.out.println("及格");
                    break;
                case 7:
                case 8:
                    System.out.println("良好");
                    break;
                case 9:
                case 10:
                    System.out.println("优秀");
                    break;
                default:
                    System.err.println("不及格");
                    break;
            }
        } else {
            System.out.println("输入数据有误");
        }
    }
}
